package com.beiju.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.beiju.common.utils.StringUtils;
import com.beiju.system.domain.SysStudent;
import com.beiju.system.mapper.SysStudentMapper;
import org.springframework.stereotype.Service;
import com.beiju.system.service.ISysStudentService;
import java.util.List;

/**
 * @version v1.0
 * @ClassName: SysStudentServiceImpl.java
 * @Description: TODO(一句话描述该类的功能)
 * @Author: BeiJu
 * @Date: 2021/10/14 9:57
 */
@Service
public class SysStudentServiceImpl extends ServiceImpl<SysStudentMapper, SysStudent> implements ISysStudentService {
	@Override
	public List<SysStudent> queryList(SysStudent sysStudent)
	{
		// 注意：mybatis-plus lambda 模式不支持 eclipse 的编译器
		// LambdaQueryWrapper<SysStudent> queryWrapper = Wrappers.lambdaQuery();
		// queryWrapper.eq(SysStudent::getStudentName, sysStudent.getStudentName());
		LambdaQueryWrapper<SysStudent> queryWrapper = Wrappers.lambdaQuery();
		if (StringUtils.isNotEmpty(sysStudent.getStudentName()))
		{
			queryWrapper.like(SysStudent::getStudentName, sysStudent.getStudentName());
		}
		if (StringUtils.isNotNull(sysStudent.getStudentAge()))
		{
			queryWrapper.eq(SysStudent::getStudentAge, sysStudent.getStudentAge());
		}
		if (StringUtils.isNotEmpty(sysStudent.getStudentHobby()))
		{
			queryWrapper.eq(SysStudent::getStudentHobby, sysStudent.getStudentHobby());
		}
		return this.list(queryWrapper);
	}
}